/* ****************************************************************************
primitives.h
-------------------------------------------------------------------------------

Copyright (c) 2017, Tain L.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

**************************************************************************** */

#if !defined(SPEARS_ASSET_PRIMITIVES_H)
#define SPEARS_ASSET_PRIMITIVES_H

#include "../mathinc/mathinc.h"

namespace Spears
{
	namespace Asset
	{
		struct atColor
		{
			atColor() :
				a(1), r(0), g(0), b(0)
			{}

			atColor(Math::decimal in_a, Math::decimal in_r, Math::decimal in_g, Math::decimal in_b) :
				a(in_a), r(in_r), g(in_g), b(in_b)
			{}

			atColor(const atColor& rhs) :
				a(rhs.a), r(rhs.r), g(rhs.g), b(rhs.b)
			{}

			atColor(atColor&& rhs) :
				a(std::move(rhs.a)),
				r(std::move(rhs.r)),
				g(std::move(rhs.g)),
				b(std::move(rhs.b))
			{}

			atColor& operator=(const atColor& rhs)
			{
				a = rhs.a;
				r = rhs.r;
				g = rhs.g;
				b = rhs.b;				

				return *this;
			}

			atColor& operator=(atColor&& rhs)
			{
				a = std::move(rhs.a);
				r = std::move(rhs.r);
				g = std::move(rhs.g);
				b = std::move(rhs.b);

				return *this;
			}

			Math::decimal a, r, g, b;
		};

		struct atPoint
		{
			atPoint() :
				x(0), y(0), z(0)
			{}

			atPoint(Math::decimal in_x, Math::decimal in_y, Math::decimal in_z) :
				x(in_x), y(in_y), z(in_z)
			{}

			atPoint(const atPoint& rhs) :
				x(rhs.x), y(rhs.y), z(rhs.z)
			{}

			atPoint(atPoint&& rhs) :
				x(std::move(rhs.x)),
				y(std::move(rhs.y)),
				z(std::move(rhs.z))
			{}

			atPoint& operator=(const atPoint& rhs)
			{
				x = rhs.x;
				y = rhs.y;
				z = rhs.z;

				return *this;
			}

			atPoint& operator=(atPoint&& rhs)
			{
				x = std::move(rhs.x);
				y = std::move(rhs.y);
				z = std::move(rhs.z);

				return *this;
			}

			Math::decimal	x, y, z;
		};

		struct atVector
		{
			atVector() :
				x(0), y(0), z(0)
			{}

			atVector(Math::decimal in_x, Math::decimal in_y, Math::decimal in_z) :
				x(in_x), y(in_y), z(in_z)
			{}

			atVector(const atPoint& rhs) :
				x(rhs.x), y(rhs.y), z(rhs.z)
			{}

			atVector(atPoint&& rhs) :
				x(std::move(rhs.x)),
				y(std::move(rhs.y)),
				z(std::move(rhs.z))
			{}

			atVector& operator=(const atVector& rhs)
			{
				x = rhs.x;
				y = rhs.y;
				z = rhs.z;

				return *this;
			}

			atVector& operator=(atVector&& rhs)
			{
				x = std::move(rhs.x);
				y = std::move(rhs.y);
				z = std::move(rhs.z);

				return *this;
			}

			Math::decimal	x, y, z;
		};

		struct atUVCoord
		{
			atUVCoord() :
				u(0), v(0)
			{}

			atUVCoord(Math::decimal in_u, Math::decimal in_v) :
				u(in_u), v(in_v)
			{}

			atUVCoord(const atUVCoord& rhs) :
				u(rhs.u), v(rhs.v)
			{}

			atUVCoord(atUVCoord&& rhs) :
				u(std::move(rhs.u)),
				v(std::move(rhs.v))
			{}

			atUVCoord& operator=(const atUVCoord& rhs)
			{
				u = rhs.u;
				v = rhs.v;

				return *this;
			}

			atUVCoord& operator=(atUVCoord&& rhs)
			{
				u = std::move(rhs.u);
				v = std::move(rhs.v);

				return *this;
			}

			Math::decimal	u, v;
		};

		struct atNormal
		{
			atNormal() :
				x(0), y(0), z(0)
			{}

			atNormal(Math::decimal in_x, Math::decimal in_y, Math::decimal in_z) :
				x(in_x), y(in_y), z(in_z)
			{}

			atNormal(const atNormal& rhs) :
				x(rhs.x), y(rhs.y), z(rhs.z)
			{}

			atNormal(atNormal&& rhs) :
				x(std::move(rhs.x)),
				y(std::move(rhs.y)),
				z(std::move(rhs.z))
			{}

			atNormal& operator=(const atNormal& rhs)
			{
				x = rhs.x;
				y = rhs.y;
				z = rhs.z;

				return *this;
			}

			atNormal& operator=(atNormal&& rhs)
			{
				x = std::move(rhs.x);
				y = std::move(rhs.y);
				z = std::move(rhs.z);

				return *this;
			}

			Math::decimal	x, y, z;
		};

		struct atFace
		{
			atFace() :
				v1(0), v2(0), v3(0)
			{}

			atFace(index vtx1, index vtx2, index vtx3) :
				v1(vtx1), v2(vtx2), v3(vtx3)
			{}

			atFace(const atFace& rhs) :
				v1(rhs.v1), v2(rhs.v2), v3(rhs.v3)
			{}

			atFace(atFace&& rhs) :
				v1(std::move(rhs.v1)),
				v2(std::move(rhs.v2)),
				v3(std::move(rhs.v3))
			{}

			atFace& operator=(const atFace& rhs)
			{
				v1 = rhs.v1;
				v2 = rhs.v2;
				v3 = rhs.v3;

				return *this;
			}

			atFace& operator=(atFace&& rhs)
			{
				v1 = std::move(rhs.v1);
				v2 = std::move(rhs.v2);
				v3 = std::move(rhs.v3);

				return *this;
			}

			index		v1, v2, v3;
		};

		struct matrix
		{
			matrix(
				Math::decimal mm00 = 1.0f, Math::decimal mm01 = 0.0f, Math::decimal mm02 = 0.0f, Math::decimal mm03 = 0.0f,
				Math::decimal mm10 = 0.0f, Math::decimal mm11 = 1.0f, Math::decimal mm12 = 0.0f, Math::decimal mm13 = 0.0f,
				Math::decimal mm20 = 0.0f, Math::decimal mm21 = 0.0f, Math::decimal mm22 = 1.0f, Math::decimal mm23 = 0.0f,
				Math::decimal mm30 = 0.0f, Math::decimal mm31 = 0.0f, Math::decimal mm32 = 0.0f, Math::decimal mm33 = 1.0f)
				: m00(mm00), m01(mm01), m02(mm02), m03(mm03)
				, m10(mm10), m11(mm11), m12(mm12), m13(mm13)
				, m20(mm20), m21(mm21), m22(mm22), m23(mm23)
				, m30(mm30), m31(mm31), m32(mm32), m33(mm33)
			{}

			union
			{
				Math::decimal	data[4][4];
				struct
				{
					Math::decimal
						m00, m01, m02, m03,
						m10, m11, m12, m13,
						m20, m21, m22, m23,
						m30, m31, m32, m33;
				};
			};
		};
	} // namespace Asset
} //namespace Spears


#endif // SPEARS_ASSET_PRIMITIVES_H